﻿using System;
using System.Collections.Generic;
using System.Data;
using System.Linq;
using System.Text;
using Bosphorus.Migrator.Core;
using Bosphorus.Migrator.Core.MigrationCommand;
using Bosphorus.Migrator.Implementation.MigrationCommand;
using Bosphorus.Migrator.Model;

namespace Bosphorus.Migrator.Facade.Demo.MigrationVersions
{
    public class VersionTwo : IMigration
    {
        public ICommand Up()
        {
            /*
             * CommandBuilder.Build
             * (
             *    Database.Alter<Table>(t => t.Name("").Column(7)).Drop<Column>("Hede"),
             *    Database.Alter<Table>("MyTable", "MyTable").Drop<Column>("Hede"),
             * );
             * 
             *       
             * 
             * 
             * */

            ICommand commandOne = Database
                .Alter<Table>("MyTable", "MyTable")
                .Drop<Column>("Hede").Command;

            ICommand commandTwo = Database
                                .Drop<Table>("OldTable")
                                .Command;

            ICommand compositeCommand = new CompositeCommand(commandOne, commandTwo);
            return compositeCommand;
        }

        public ICommand Down()
        {
            return Database.Alter<Table>("MyTable", "MyTable")
                .Add<Column>("Hede", SqlDbType.VarChar).Command;
        }

        public int Version
        {
            get { return 2; }
        }
    }
}
